local alliance1 = fk.CreateSkill{
  name = "alliance1&",
}

Fk:loadTranslationTable{
  ["alliance1&"] = "合纵A",
  [":alliance1&"] = "出牌阶段，你可将有“合”标记的合计至多三张手牌交给与你势力不同或未确定势力的一名角色，若你以此法交给与你势力不同的角色牌，你摸等量的牌。",
  ["#alliance1&"] = "合纵A：你可将至多3张有“合”标记的手牌交给势力不同或无势力的角色，前者你摸等量的牌",
}

local H = require "packages/ol_hegemony/util"
local HG = require "packages/new_heg_diy_my/util"

alliance1:addEffect("active", {
  prompt = "#alliance1&",
  anim_type = "support",
  can_use = function(self, player)
    return table.find(player:getCardIds(Player.Hand), function(id) return HG.HasMark(Fk:getCardById(id), "@@alliance-public", MarkEnum.CardTempMarkSuffix) end)
     and player:usedSkillTimes("alliance&", Player.HistoryPhase) == 99
  end,
  max_card_num = 3,
  min_card_num = 1,
  card_filter = function(self, player, to_select, selected)
    return HG.HasMark(Fk:getCardById(to_select), "@@alliance-public", MarkEnum.CardTempMarkSuffix) 
     and table.contains(Self.player_cards[Player.Hand], to_select) and #selected + player:getMark("wk_heg__alliance1-phase") < 3
  end,
  target_num = 1,
  target_filter = function(self, player, to_select, selected, selected_cards)
    if #selected == 0 and #selected_cards >= 1 and #selected_cards <= 3 then
      return H.canAlliance(player, to_select)
    end
  end,
  on_use = function(self, room, effect)
    local target = effect.tos[1]
    local player = effect.from
    local ret = H.compareKingdomWith(target, player, true)
    room:moveCardTo(effect.cards, Card.PlayerHand, target, fk.ReasonGive, alliance1.name, nil, true, player.id)
    if ret and not player.dead then
      player:drawCards(#effect.cards, alliance1.name)
    end
    room:addPlayerMark(player, "wk_heg__alliance1-phase", #effect.cards)
  end
})

return alliance1